/**
 * 
 */

package com.admissions.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.admissions.R;
import com.admissions.model.ItemInfo;

/**
 * @author Bkav-DangNVb
 *
 */
public class TuyenSinhAdapter extends BaseAdapter {
    private ArrayList<ItemInfo> items;

    private Context mContext;

    public TuyenSinhAdapter(Context context, ArrayList<ItemInfo> items) {
        this.mContext = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.item_layout, null, false);
        }

        ImageView icon = (ImageView) convertView.findViewById(R.id.item_icon);
        TextView name = (TextView) convertView.findViewById(R.id.item_name);
        TextView description = (TextView) convertView.findViewById(R.id.item_description);

        ItemInfo itemInfo = items.get(position);

        icon.setImageResource(R.drawable.ic_item);
        name.setText(itemInfo.name);
        description.setText(itemInfo.description);

        convertView.setTag(itemInfo);
        convertView.setBackgroundResource(R.drawable.tuyen_sinh_2012_item_list_bg);

        return convertView;
    }
}
